//package com.touchfired.common.event.handler.impl;
//
//import com.alibaba.fastjson.JSONObject;
//import com.touchfired.common.constants.*;
//import com.touchfired.common.message.BaseMessage;
//import io.netty.channel.ChannelHandlerContext;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDateTime;
//
///**
// * @Description 连接成功事件码处理器
// * @Author 幸佳俊
// */
//@Component
//public class EventCodeRoomCreatedHandler extends BaseEventCodeHandler {
//
//    public EventCodeRoomCreatedHandler() {
//        super(EventCode.ROOM_CREATED);
//    }
//
//    @Override
//    public EventCodeHandler doHandle(ChannelHandlerContext ctx, ClientInfo clientInfo, BaseMessage message) throws Exception {
//        JSONObject createRoomParams = message.getOtherMap();
//        if (createRoomParams != null) {
//            Integer playerNum = (Integer) createRoomParams.get(GlobalConstants.PLAYER_NUM);
//            Integer spyerNum = (Integer) createRoomParams.get(GlobalConstants.SPYER_NUM);
//            String roomName = (String) createRoomParams.get(GlobalConstants.ROOM_NAME);
//            RoomInfo roomInfo = new RoomInfo();
//            roomInfo.setCreateClient(clientInfo.getLongId());
//            roomInfo.setCreateTime(LocalDateTime.now());
//            roomInfo.setRoomName(StringUtils.isNotBlank(roomName) ? roomName : clientInfo.getName());
//            roomInfo.getRoomClients().add(clientInfo.getLongId());
//            roomInfo.setGameRule(new GameRule(playerNum, spyerNum));
//
////            String roomId = serverContext.addRoomInfo(roomInfo);
////            serverContext.updateClientInfo(clientInfo.setRoomId(roomId));
//
////            message.getOtherMap().put(GlobalConstants.ROOMID, roomId);
////            return eventHandle(ctx, clientInfo, message, EventCode.ROOM_PADDING);
//            return null;
//        }
//        return null;
//    }
//}
